﻿@using LY.Entity
@{
    ViewBag.Title = "添加项目";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<link href="~/Content/validform.css" rel="stylesheet" />
@section style {
    <style type="text/css">
        #itemtable {
            width: 80%;
            margin: auto;
            font-size: 16px;
        }

            #itemtable td {
                text-align: center;
            }
    </style>
}

@section scripts{
    <script type="text/javascript">
        //function geiqian() {
            //先将顺序拼接好
            //    if ($("#sftuserName").val() == null || $("#sftuserName").val() == "") {
            //        alert("请先开通盛付通账号");
            //        window.location.href = "/Account/AccountInfo";
            //        return;
            //    }

            //    if ($("#availableAmount").val() < Math.floor($("#result").val())) {
            //        //alert($("#result").val());
            //        alert("余额不足，请先充值");
            //        alert($("#availableAmount").val());
            //        alert($("#result").val());
            //        window.location.href = "/Account/Recharge";
            //        return;
            //    }

            //    if ($("#agreeWithhold").val() == "1") { //已开通自动投标
            //        $.ajax({
            //            url: "/UserOrder/ZiDongTouBiao",
            //            type: "Post",
            //            success: function (data) {
            //                if (data == "true") {
            //                    window.location.href = "/UserOrder/ZiDongTouBiaoCallBack?result=true";
            //                } else {
            //                    window.location.href = "/UserOrder/ZiDongTouBiaoCallBack?result=false";
            //                }
            //                return;
            //            },
            //            data: "creditAmount=" + $("#sftcreditAmount").val() + "&issueBidNo=" + $("#sftissueBidNo").val() + "&submitBidNo=" + $("#sftsubmitBidNo").val()
            //                + "&projectId=" + $("#projectId").val(),
            //        });
            //        return;
            //    }

            //    //var orderNum = CreateOrderNo();
            //    var sign = "callback=" + $("#sftcallback").val() + "&creditAmount=" + $("#sftcreditAmount").val() + "&discountAmount=0.00" +
            //        "&issueBidNo=" + $("#sftissueBidNo").val() + "&merchantNo=" + $("#sftmerchantNo").val() + "&notifyUrl=" + $("#sftnotifyUrl").val() +
            //        "&submitBidNo=" + $("#sftsubmitBidNo").val() + "&timestamp=temp" + "&userName=" + $("#sftuserName").val();
            //    sign = sign.replace(/\&/g, "|");
            //    $.ajax({
            //        url: "/UserOrder/AddTouBiaoFundsFlow",
            //        type: "Post",
            //        success: function (data) {
            //            var time = data.substring(0, 14);
            //            var sign2 = data.substring(14);
            //            $("#sfttimestamp").val(time);
            //            $("#sftsign").val(sign2);
            //            $("#sftTouBiaoForm").submit();
            //        },
            //        data: "sign=" + sign + "&orderNo=" + $("#sftsubmitBidNo").val() + "&amount=" + $("#sftcreditAmount").val() + "&projectId=" + $("#projectId").val(),
            //    });
            //}

            //拼接订单号，到后台替换时间
            //function CreateOrderNo() {
            //    var num = "";
            //    for (var i = 0; i < 5; i++) {
            //        num += Math.floor(Math.random() * 10);
            //    }
            //    return "quanju" + "orderNum" + num;
        //}
        function geiqian() {
            var sign = $("#sftName").val() + "|" + $("#sftVersion").val() + "|" + $("#sftCharset").val() + "|" + $("#sftMsgSender").val() + "|"
                + $("#sftOrderNo").val() + "|" + $("#sftOrderAmount").val() + "|" + "OrderTime" + "|" + $("#sftInstCode").val() + "|" + $("#sftPageUrl").val() + "|"
                + $("#sftBackUrl").val() + "|" +$("#sftNotifyUrl").val() + "|" + $("#sftBuyerIp").val() + "|" +$("#sftSignType").val() + "|" ;

            $.ajax({
                url: "/UserOrder/AddZhiFuFundsFlow",
                    type: "Post",
                    success: function (data) {
                        var time = data.substring(0, 14);
                        var sign2 = data.substring(14);
                        $("#sftOrderTime").val(time);
                        $("#sftSignMsg").val(sign2);
                         $("#ZhiFuForm").submit();
                        
                        //$.dialog({
                        //    content:$("#ZhiFuForm").html(),
                        //    width: '1200px',
                        //    height: '800px',
                        //    lock: true,
                        //    background: '#000', /* 背景色 */
                        //    opacity: 0.5,       /* 透明度 */
                        //    drag: false,
                        //    resize: false,
                        //    close: function () {
                        //        parent.location.reload();
                        //        return true;
                        //    }
                        //});
                    },
                    data: "orderNo=" + '@ViewBag.serialNumber' + "&amount=" + $("#sftOrderAmount").val() + "&projectId=" + $("#projectId").val() + "&sign=" + sign,
            });
        }
  
    </script>

}
<script src="~/Content/assets/app/common/ajaxupload.js"></script>
<script src="~/Scripts/Validform_v5.3.2_min.js"></script>
<script src="~/Scripts/Validform_Datatype.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>


<div class="line10"></div>
<div class="container">
    <div class="order-process">
        <ul>
            <li class="active">订单详细填写页</li>
            <li class="active">订单信息确认页</li>
            <li>支付</li>
            <li>完成</li>
        </ul>
    </div>

    <div class="additem">

        <input type="hidden" id="projectId" value="@ViewBag.projectId"/>
        <div style="margin: 10px 0px;">
            <h4 id="editInfo" style="font-size: 18px;">@ViewBag.ProjectName</h4>
        </div>
        <div style="height: 2px; background-color: red;"></div>
        <dl>
            <dt>订单号：</dt>
            <dd>
                @ViewBag.serialNumber
            </dd>
        </dl>
        <dl>
            <dt>收货人：</dt>
            <dd>
                @ViewBag.contacts
            </dd>
        </dl>
        <dl>
            <dt>详细地址：</dt>
            <dd>
                @ViewBag.address
            </dd>
        </dl>
        <dl>
            <dt>联系电话：</dt>
            <dd>
                @ViewBag.phone
            </dd>
        </dl>
        @{
            if (ViewBag.NeedInvoice != 0)
            {
            <dl>
                <dt>发票抬头：</dt>
                <dd>
                    @ViewBag.InvoiceTitle
                </dd>
            </dl>
            }
            
        }
        <dl>
            <dt>备注：</dt>
            <dd>
                @ViewBag.remark
            </dd>
        </dl>
    </div>
    <hr />
    @{
        R_ProjectItem item = @ViewBag.item;
    }
    <div>

        <table id="itemtable" cellspacing="2">
            <tr style="background-color: rgb(249,207,207); height: 40px;">
                <td>项目名称</td>
                <td>发起人</td>
                <td>回报</td>
                <td>支持金额</td>
                <td>运费</td>
            </tr>
            <tr style="background-color: #ddd; height: 40px;">
                <td>@ViewBag.projectName</td>
                <td>@ViewBag.memberName</td>
                <td>@item.RedoundContent</td>
                <td>￥@item.Amount</td>
                <td>￥@item.Freight</td>
            </tr>
            <tr style="background-color: #ddd; height: 60px;">
                <td colspan="5">
                    @*<form id="sftTouBiaoForm" action="@ViewBag.sftAddress/custodian/submitBid.html" method="post">*@
                    <form id="ZhiFuForm" action="https://mas.shengpay.com/web-acquire-channel/cashier.htm" method="post">
                        <div>

                            @{
                                decimal? result;
                                if (item.Freight == null)
                                {
                                    result = item.Amount;
                                }
                                else
                                {
                                    result = item.Amount + item.Freight;
                                }
                            }
                            合计支付: ￥@result

                            <input type="button" class="button" value="去付款" style="width: 100px;" onclick="geiqian()" />
                            @{
                                if (ViewBag.sign != null)
                                {
                                    <a class="button" style="width: 100px;" href="/UserOrder/AddOrder?ProjectId=@item.ProjectId&itemid=@item.Id&id=@ViewBag.orderId">返回</a>
                                }
                            }

                        </div>
                        @*<input type="hidden" name="merchantNo" id="sftmerchantNo" value="@ViewBag.merchantNo" />
                        <input type="hidden" name="timestamp" id="sfttimestamp" value="" />
                        <input type="hidden" name="issueBidNo" id="sftissueBidNo" value="@ViewBag.BiaoNo" />
                        <input type="hidden" name="submitBidNo" id="sftsubmitBidNo" value="@ViewBag.serialNumber" />
                        <input type="hidden" name="userName" id="sftuserName" value="@ViewBag.SFTUserName" />
                        <input type="hidden" name="creditAmount" id="sftcreditAmount" value="@result" />
                        <input type="hidden" name="discountAmount" value="0.00" />
                        <input type="hidden" name="callback" id="sftcallback" value="@ViewBag.backAddress/UserOrder/OrderConfirmCallBack" />
                        <input type="hidden" name="notifyUrl" id="sftnotifyUrl" value="@ViewBag.backAddress/Pay/OrderConfirmNotifyUrl" />
                        <input type="hidden" name="sign" id="sftsign" value="" />
                        <input type="hidden" id="result" value="@result"/>
                        <input type="hidden" id="agreeWithhold" value="@ViewBag.agreeWithhold"/>
                        <input type="hidden" id="availableAmount" value="@ViewBag.availableAmount"/>*@
                        
                        <input type="hidden" name="Name" id="sftName" value="B2CPayment"/>
                        <input type="hidden" name="Version" id="sftVersion" value="V4.1.1.1.1"/>
                        <input type="hidden" name="Charset" id="sftCharset" value="UTF-8"/>
                        <input type="hidden" name="MsgSender" id="sftMsgSender" value="@ViewBag.zFmysenderId"/>
                        
                        <input type="hidden" name="OrderNo" id="sftOrderNo" value="@ViewBag.serialNumber"/>
                        <input type="hidden" name="OrderAmount" id="sftOrderAmount" value="@result"/>
                        <input type="hidden" name="OrderTime" id="sftOrderTime" value=""/>
                        <input type="hidden" name="InstCode" id="sftInstCode" value="SDTBNK"/>
                        <input type="hidden" name="PageUrl" id="sftPageUrl" value="@ViewBag.backAddress/UserOrder/OrderConfirmCallBack"/>
                        <input type="hidden" name="BackUrl" id="sftBackUrl" value="@ViewBag.backAddress/Default/Index"/>
                        <input type="hidden" name="NotifyUrl" id="sftNotifyUrl" value="@ViewBag.backAddress/Pay/OrderConfirmNotifyUrl"/>
                        <input type="hidden" name="BuyerIp" id="sftBuyerIp" value="@ViewBag.BuyerIp"/>
                        <input type="hidden" name="SignType" id="sftSignType" value="MD5"/>
                        <input type="hidden" name="SignMsg" id="sftSignMsg" value=""/>
                    </form>
                </td>
            </tr>
        </table>
        
        <br/>


    </div>
</div>

